/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#ifndef INCLUDE_SHADER_RAY
#define INCLUDE_SHADER_RAY


#define DEF_OBTYPE_Mesh           0
#define DEF_OBTYPE_ParallelLight  1
#define DEF_OBTYPE_PointLight     2
#define DEF_OBTYPE_SpotLight      3


#ifdef __cplusplus

#include <basic_def.h>

// GLSL Type
using uint = unsigned int;
using uint64_t = uint64;

#define inout

#else

#define Inline

#define M_PI 3.1415926535


#endif





struct S_Material {
	vec3	m_color;
	int     m_colorTex;

	vec3	m_emission;		//����
	int		m_emissionTex;


	float m_reflect;		//�����
	int m_reflectTex;


	float m_refract;		//�����
	int   m_refractTex;


	float m_roughness;		//�ֲڶ�
	int   m_roughnessTex;


	float m_alpha;
	int   m_alphaTex;


	float m_transmission;	//͸��
	int   m_normalTex;


	float m_anisotropy;		//����������
	float m_overflowColor;	//��ɫ
	
	
	int	 m_shaderIndex;    //�ص���ɫ������
	uint m_LigthMask; 
	
};


struct S_ShaderMaterialTexture {
	int m_colorTex;
	int m_emissionTex;
	int m_reflectTex;
	int m_roughnessTex;
	int m_alphaTex;
};


struct S_FaceElement {
	int  FacesMooth;	 //面平滑模式
	int  MaterialID;     //面材质ID
	int  ObType;         //物体类型
	uint FaceColor;
};

struct S_Ray {
	vec3 Color;
	vec3 Normal;
	
	uint Depth;
	uint RayType;
	uint Ligth_Type_ID;

	float Dis;
	float irradiance;
	float Alpha;
	float LigthDis;
	uint  LigthMask;


	//vec3 Origin;
	//vec3 Dir;
};


struct S_ObMesh {
	uint64_t m_AddressVertex;
	uint64_t m_AddressUV;
	uint64_t m_AddressUVIndex;
	uint64_t m_AddressIndex;
	uint64_t m_AddressFaces;
	uint     m_ObType;
	uint     m_ObDataID;
};


struct S_Geom {
	vec3 vert;
	
	vec3 boundOffset;
	vec3 boundSize;

	vec3 uv;

	uint uvLayerNum;
	uint uvLayerOffset;
	
	uint uvIndexOffset0;
	uint uvIndexOffset1;
	uint uvIndexOffset2;
	uint uvIndexOffset3;
	uint uvIndexOffset4;
	uint uvIndexOffset5;
	uint uvIndexOffset6;
	uint uvIndexOffset7;
};

struct S_GlobalParam {
	uint64_t m_AddressI32;
	uint64_t m_AddressF32;
	uint64_t m_AddressVec2;
	uint64_t m_AddressVec3;
	uint64_t m_AddressUVec2;
	uint64_t m_AddressUVec3;
	uint64_t m_AddressUVec4;
	uint64_t m_AddressMat44;
	uint64_t m_AddressSampleCurve;

	uint64_t m_AddressLigthParallel;
	uint64_t m_AddressLigthPoint;
	uint64_t m_AddressLigthArea;
	uint64_t m_AddressLigthSpot;

	uint64_t m_AddressMaterial;
};


struct S_SceneDataCall {
	vec3 Vert;
	vec3 Normal;
	vec3 rayDir;
	vec3 ligthDir;
	vec3 barycentrics;

	//输出颜色
	vec3 Color;
	

	uint InstanceIndex;
	uint PrimitiveIndex;
	//uint GeometryIndex;
	
	float irradiance;
	float reflect;
	float roughness;
	float transmission;
	float alpha;
	//float dis;
	int   MaterialID;    
	//uint  Depth;
};





struct GLSL_RenderFrame {
	uint m_Frame;
	uint m_ParallelLightNum;
	uint m_PointLightNum;
	uint m_SpotLightNum;
	uint m_AreaLightNum;
	//��������
	uint m_BouncesNum;
	//��������
	uint m_SamplesNum;

	int m_world_ShaderID;

	int m_ViewOffset_X;
	int m_ViewOffset_Y;
};






#endif


